package com.ipcoder;

import java.io.*;
import java.net.Socket;

public class SocketTcp {
    public static void main(String[] args) throws IOException {
        //1.建立TCPsocket套接字
        Socket sk=new Socket("192.168.18.24",10000);
        System.out.println("用户录入数据通过TCP传送到指定用户:");
        //建立输入流
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        //建立输出流
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(sk.getOutputStream()));
        //字符串
        String line;
        //读取输入流中的数据
        while((line=br.readLine())!=null){
            if("886".equals(line)){
                break;
            }else{
                bw.write(line);
                //换行
                bw.newLine();
                //刷新
                bw.flush();
            }
        }
        //关闭相关流 和套接字
        br.close();
        bw.close();
        sk.close();
    }
}
